package com.yanqingying.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yanqingying.Clazz;
import com.yanqingying.ClazzQueryParam;
import com.yanqingying.PageBean;
import com.yanqingying.Result;
import com.yanqingying.mapper.ClazzMapper;
import com.yanqingying.service.ClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Autowired
    ClazzMapper clazzMapper;
    public PageBean getPage(ClazzQueryParam clazz) {
        PageHelper.startPage(clazz.getPage(), clazz.getPageSize());
        Page<Clazz> pageBen = clazzMapper.list(clazz);
        return new PageBean(pageBen.getTotal(),pageBen.getResult());
    }

    @Override
    public void dele(Integer id) {
        clazzMapper.dele(id);
    }

    @Override
    public void insert(Clazz clazz) {
        clazz.setCreateTime(LocalDateTime.now());
        clazz.setUpdateTime(LocalDateTime.now());
        clazzMapper.insert(clazz);
    }

    @Override
    public Clazz geta(Integer id) {
        return clazzMapper.geta(id);
    }

    @Override
    public void upDate(Clazz clazz) {
        clazz.setUpdateTime(LocalDateTime.now());
        clazzMapper.upDate(clazz);
    }

    @Override
    public void getList(Integer ids) {
        clazzMapper.getList(ids);
    }


}
